package com.jrx.anytxn.param.mapper.ext;

import com.jrx.anytxn.param.entity.TlBillTransDetil;
import com.jrx.anytxn.param.mapper.base.TlBillTransDetilMapper;
import org.apache.ibatis.annotations.Param;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

public interface ExtTlBillTransDetilMapper extends TlBillTransDetilMapper {

    /**
     * 保存
     * @param item
     * @return int
     */
    int insertbatch(List<TlBillTransDetil> item);

    /**
     * 根据商户订单查询
     * @param  loanNumber
     * @return TlBillTransDetil
     */
    TlBillTransDetil selectByLoanNumber(String loanNumber);

    void batchUpdate(List<TlBillTransDetil> item);

    int countByTenantIdAndBusDateAndTransType(@Param("tenantId") String tenantId,
                                              @Param("businessDate") Date businessDate,
                                              @Param("transType") String transType);

    BigDecimal sumByTenantIdAndBusDateAndTransType(@Param("tenantId") String tenantId,
                                                   @Param("businessDate") Date businessDate,
                                                   @Param("transType") String transType);

    int countByTenantIdBusDateAndTransStatusAndTransType(@Param("tenantId") String tenantId,
                                                         @Param("businessDate") Date businessDate,
                                                         @Param("transStatus") String transStatus,
                                                         @Param("transType") String transType);

    BigDecimal sumByTenantIdBusDateAndTransStatusAndTransType(@Param("tenantId") String tenantId,
                                                              @Param("businessDate") Date businessDate,
                                                              @Param("transStatus") String transStatus,
                                                              @Param("transType") String transType);

    /**
     * 根据租户ID查询
     *
     * @param tenantId 租户ID
     */
    List<TlBillTransDetil> selectByTenIdAndBusDateAndComFlag(@Param("tenantId") String tenantId,
                                                             @Param("businessDate") Date businessDate,
                                                             @Param("compareFlag") String compareFlag);

    /**
     * 根据业务日期删除
     * @param businessDate Date
     * @return int
     */
    int deleteByBusDate(@Param("businessDate") Date businessDate);

    /**
     * 根据业务日期更新比对状态
     * @param compareFlag String
     * @param dataFrom String
     * @param businessDate Date
     * @return int
     */
    void updateComFlagByFromAndBusDate(@Param("compareFlag") String compareFlag,
                                       @Param("dataFrom") String dataFrom,
                                       @Param("businessDate") Date businessDate);


}
